package com.wanjl.ssm01.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * @author WanJl
 * @version 1.0
 * @title JdbcConfig
 * @description
 * @create 2024/11/10
 */
public class JdbcConfig {
    @Value("${mysql.jdbc.driver}")
    private String driverClassName;
    @Value("${mysql.jdbc.url}")
    private String url;
    @Value("${mysql.jdbc.username}")
    private String username;
    @Value("${mysql.jdbc.password}")
    private String password;

    @Bean
    public DataSource getDruidDataSource() {
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName(driverClassName);
        ds.setUrl(url);
        ds.setUsername(username);
        ds.setPassword(password);
        return ds;
    }
}
